<template>
    <div>
      <Topbar/>
<!--      我的淘宝组件-->
      <div id="profile">
        <div id="my">我的商城</div>
        <div class="nav" @click="activeNav = 1"> 首页</div>
        <div class="nav"> 消息</div>
      </div>
<!--     下一栏商品区域-->
      <div class="main">
        <div class="side">
          <div id="all">全部功能</div>
          <div  v-for="(item,i) in tabData" :key="i" class="side-item"  :class="[activeNav ===i ? 'active' :'']"  @click="showNav(i)" >{{item}}</div>
        </div>
        <div class="right"  v-if="activeNav === 0">
<!--          tab栏-->
          <div class="tab">
            <div v-for="(item ,i ) in navData" :key="i" class="tab-item" @click="showItem(i)" :class="[activeIndex ===i ?'border-button':'']">{{item}} </div>
          </div>
<!--          所有订单、代付款、待发货、待收货-->
            <div class="order">
<!--              header栏-->
              <div class="header">
                <span class="header-item" style="width: 331px">宝贝</span>
                <span class="header-item" style="width: 87px">单价</span>
                <span class="header-item" style="width: 44px">数量</span>
                <span class="header-item" style="width: 104px">原价</span>
                <span class="header-item" style="width: 104px">实付款</span>
                <span class="header-item" style="width: 95px">交易状态</span>
              </div>
              <div class="orderC">
                <div class="top">
                  <div class="check"></div>
                  <div class="time">2020-03-13</div>
                </div>
                <div class="content" v-for="(item,i ) in goods_info" :key="i">
                  <div class="img">
                    <img :src="item.pic_url" width="80px" alt="">
                  </div>
                  <div class="name" >{{item.goods_name}}</div>
                  <div class="price" style="width: 87px">{{item.goods_price}}</div>
                  <div class="count" style="width: 44px">{{item.goods_count}}</div>
                  <div class="money" style="width: 104px;height: 100%;">{{item.goods_price}}</div>
                  <div class="money" style="width: 104px">{{item.goods_price}}</div>
                  <div class="state" style="width: 95px">已付款</div>
                </div>
              </div>
            </div>
        </div>
      </div>
    </div>
</template>

<script>
import Topbar from '../commom/Topbar'
export default {
  name: 'ShopOrder',
  data() {
    return {
      //  order列表
      order_list: [],
      //  router传递过来的query参数
      goods_info: [],
      //  激活的tab栏
      activeIndex: 1,
      //  激活的nav栏
      activeNav: 0,
      //  tab栏的数据
      tabData: [
        '我的订单', '我的购物车', '我的XX'
      ],
      //  导航栏里的数据
      navData: [
        '所有订单', '待付款', '待发货', '待收货'
      ]
    }
  },
  components: {
    Topbar
  },
  created () {
    this.getInfo()
  },
  computed: {},
  methods: {
    //  测试代码
    getInfo() {
      this.goods_info = this.$route.query.info
      console.log(this.goods_info)
    },
    //  tab栏的点击显示
    showItem(id) {
      console.log(id)
      this.activeIndex = id
    },
    //  左侧nav栏的点击
    showNav(id) {
      console.log(id)
      this.activeNav = id
      if (id === 1) {
        this.$router.push('/cart')
      }
    }
  }
}
</script>

<style lang="less" scoped>
  #profile{
    height: 61px;
    width: 100%;
    background: rgb(255,0,54);
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
    color: white;
    >#my{
      width: 140px;
      height: 36px;
      margin-left: 10px;
      line-height: 36px;
      font-size: 30px;
    }
    >.nav{
      margin-left: 30px;
      cursor: pointer;
    }
  }
  .main{
    width: 80%;
    margin-left: 10%;
    margin-right: 10%;
    padding-top: 20px;
    /*background: #000;*/
    >.side{
      width: 107px;
      height: 20px;
      float: left;
      >#all{
        font-size: 20px;
        color: rgb(255,0,54);
        margin-bottom: 6px;
      }
      >.side-item{
        margin-bottom: 6px;
        cursor: pointer;
      }
      >.active{
        color: rgb(255,0,54);
      }
    }
    >.right{
      /*width: 80%;*/
      /*background: #ff0000;*/
      width: 80%;
      float: left;
      margin-left: 30px;
      >.tab {
        display: flex;
        flex-direction: row;
        justify-content: start;
        align-items: center;
        background: #f5f5f5;
        >.tab-item{
          width: 109px;
          height: 36px;
          line-height: 36px;
          font-weight: 700;
          cursor: pointer;
        }
        >.border-button{
          border-bottom: 3px solid rgb(255,0,54) ;
        }
      }
      >.order {
        display: flex;
        flex-direction: column;
        justify-content: start;
        align-items: start;
        >.header{
          height: 39px;
          width: 100%;
          margin-top: 30px;
          margin-bottom: 30px;
          background: #f5f5f5;
          line-height: 39px;
          >.header-item{
            text-align:center;
            display: inline-block;
          }
        }
          >.orderC {
            width: 100%;
            border: 1px solid #ececec;
            >.top{
              height: 42px;
              line-height: 42px;
              width: 100%;
              background: #f5f5f5;
              display: flex;
              justify-content: start;
              align-items: center;
              >.check{
                height: 12px;
                width: 12px;
                border: 1px solid #f1f1f1;
                background: white;
                border-radius: 4px;
                margin-left: 10px;
              }
              >.time{
                font-size: 12px;
                margin-left: 30px;
                font-weight: 700;
              }
            }
            > .content {
              display: flex;
              flex-direction: row;
              justify-content: start;
              align-items: center;
              padding-left: 10px;
              padding-top: 10px;
              padding-bottom: 10px;
              >.img{
                width: 80px;
                height: 80px;
                background: #000;
                margin-right: 10px;
                border: 1px solid #f3f3f3;
              }
              >.name{
                font-size: 12px;
                width: 230px;
                margin-right: 23px;
              }
              >.money{
                border-right: 1px solid #f2f2f2;
              }
            }
          }
      }
    }
  }
</style>
